home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / v0_98 / btxbst.doc < prev    next >
Text File  |  1990-10-02  |  58KB  |  2,315 lines

  1. %NAME: btxbst.doc
  2. # if 0
  3. % BibTeX `plain' family
  4. % modified to ouput fields in French; shapiro@corto.inria.fr 30-oct-87
  5. % Further modified for 'alpha3' and 'long' styles 3-nov-87
  6. % and for 'key' and 'skey' 1-jan-88
  7. % and for `paren' 23-march-89
  8. # endif 0
  9.     % version 0.98c for BibTeX versions 0.98i or later, LaTeX version 2.08
  10.     % Copyright (C) 1985, all rights reserved
  11.     % Copying of this file is authorized only if either
  12.     % (1) you make absolutely no changes to your copy, including name, or
  13.     % (2) if you do make changes, you name it something other than
  14.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst
  15.     % This restriction helps ensure that all standard styles are identical
  16. # if 0
  17. % This is file btxbxt.doc; it helps document bibliography styles,
  18. % and is also a template file that you can use to make
  19. % several different style files, if you have access to a C preprocessor.
  20. % For example, the standard styles were made by something like
  21. %    cpp -P -DPLAIN btxbst.doc | sed -e '/^$/d' > plain.bst
  22. %    cpp -P -DUNSRT btxbst.doc | sed -e '/^$/d' > unsrt.bst
  23. %    cpp -P -DALPHA btxbst.doc | sed -e '/^$/d' > alpha.bst
  24. %    cpp -P -DABBRV btxbst.doc | sed -e '/^$/d' > abbrv.bst
  25. % A French version of (say) abbrv is created by
  26. %    cpp -P -DABBRV -DFRENCH btxbst.doc | sed -e '/^$/d' > fabbrv.bst
  27. % There are also new styles created by defining ALPHA3, KEY, SKEY,
  28. % LONG, or PAREN.  For each style respectivley the label is:
  29. %       ALPHA3  first 3 letters of 1st author's name + year [Lam85]
  30. %       LONG    1st author's full name + year [Lamport 85]
  31. %       PAREN   1st author's name + date in parenthesis [Lamport (85)]
  32. %       KEY     the bibtex key, the bibliogrpahy is unsorted [latex:book]
  33. %       SKEY    the bibtex key, sorted by 1st author's name&year [latex:book]
  34. % The last two styles are intended for printing the database itself.
  35. %
  36. % If you don't have access to cpp you can edit this file by hand to
  37. % imitate the preprocessor, with the following explanation of the C
  38. % preprocessor constructs used here.
  39. %
  40. % The output of the preprocessor is the same as the input, except that certain
  41. % lines will be excluded (and some blank lines will be added).  The sequence
  42. %    #if VAR
  43. %        lines to be included when VAR is not zero
  44. %    #else
  45. %        lines to be included when VAR is zero
  46. %    #endif
  47. % (with the #-signs appearing in column 1) means that one set or the other of
  48. % the lines are to be included depending on the value of VAR.
  49. % The #else part is optional.  Comments can be added after #else and #endif.
  50. % The '# if 0' ... '#endif' sequence is used to eliminate unnecessary
  51. % comments from the output.
  52. % Variables can be set by
  53. %    #define VAR value
  54. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  55. % to see if it has none.
  56. % Another #if form used in this file is #if !VAR, which includes the lines
  57. % after the #if only if VAR is zero.
  58. %
  59. % Convention: Use all uppercase identifiers for these preprocessor variables
  60. % so you can spot them easily
  61. %
  62. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  63. % or ABBRV (though PLAIN will be used by default if none is given),
  64. % and the following lines will set various boolean variables to control the
  65. % various lines that are chosen from the rest of the file.
  66. % Each boolean variable should be set true (1) or false (0) in each style.
  67. % Here are the current variables, and their meanings:
  68. %    LAB_ALPH:    an alphabetic label is used (if false then a numeric
  69. %                label is used)
  70. %    SORTED:        the entries should be sorted by label (if nonnumeric)
  71. %                and other info, like authors (if false, then
  72. %                entries remain in order of occurrence)
  73. %    NAME_FULL:    the authors, editors, etc., get the full names as
  74. %                given in the bibliograph (if false, the first
  75. %                names become initials)
  76. %    ATIT_LOWER:    titles of non-"books" (e.g., articles) should be
  77. %                converted to lower-case, except the first letter
  78. %                (if false then they appear as in the database)
  79. %    MONTH_FULL:    months are spelled out in full (if false, then
  80. %                they're abbreviated)
  81. %    JOUR_FULL:    macro journal names are spelled out in full
  82. %                (if false then they are abbreviated, currently
  83. %                as they appear in ACM publications)
  84. %       LBKEYS:         use the database key as the citation label
  85. % Furthermore the variable ALPHA_LONG may have one of the following
  86. % values, when LAB_ALPH is 1, giving the following citation alphabetic
  87. % label format:
  88. % 0 [Lam85] for single author (or editor or key): first 3 letters of last name
  89. %   [SW79]  (first letters of last names) for multiple authors
  90. % 1 [Lam85] for single author (or editor or key)
  91. %   [Str79]  (first 3 letters of 1st author's last name) for multiple authors
  92. % 2 [Lamport 85] for single author (or editor or key): full last name
  93. %   [Strunk 79]  (full last name of 1st author) for multiple authors
  94. # endif 0
  95.  
  96. #ifndef UNSRT
  97. #   ifndef ALPHA
  98. #    ifndef ABBRV
  99. #           ifndef ALPHA3
  100. #               ifndef LONG
  101. #                   ifndef KEY
  102. #                       ifndef SKEY
  103. #                           ifndef PAREN
  104. #                              define PLAIN 1
  105. #                           endif
  106. #                       endif
  107. #                   endif
  108. #               endif
  109. #           endif
  110. #    endif
  111. #   endif
  112. #endif
  113. #ifdef PLAIN
  114. % plain style (sorted numbers)
  115. #   define LAB_ALPH 0
  116. #   define SORTED 1
  117. #   define NAME_FULL 1
  118. #   define ATIT_LOWER 1
  119. #   define MONTH_FULL 1
  120. #   define JOUR_FULL 1
  121. #   define LBKEYS 0
  122. #endif
  123. #ifdef UNSRT
  124. % unsrt style (unsorted numbers)
  125. #   define LAB_ALPH 0
  126. #   define SORTED 0
  127. #   define NAME_FULL 1
  128. #   define ATIT_LOWER 1
  129. #   define MONTH_FULL 1
  130. #   define JOUR_FULL 1
  131. #   define LBKEYS 0
  132. #endif
  133. #ifdef ALPHA
  134. % alpha style (sorted short alphabetics)
  135. #   define LAB_ALPH 1
  136. #   define ALPHA_LONG 0
  137. #   define SORTED 1
  138. #   define NAME_FULL 1
  139. #   define ATIT_LOWER 1
  140. #   define MONTH_FULL 1
  141. #   define JOUR_FULL 1
  142. #   define LBKEYS 0
  143. #endif
  144. #ifdef ALPHA3
  145. % alpha3 style (sorted short alphabetics, 3 letters of 1st author only)
  146. #   define LAB_ALPH 1
  147. #   define ALPHA_LONG 1
  148. #   define SORTED 1
  149. #   define NAME_FULL 1
  150. #   define ATIT_LOWER 1
  151. #   define MONTH_FULL 1
  152. #   define JOUR_FULL 1
  153. #   define LBKEYS 0
  154. #endif
  155. #if defined(LONG) || defined(PAREN)
  156. #   ifdef LONG
  157. % long style (sorted long alphabetics, full name of 1st author only)
  158. #   else
  159. % parenthesised style ( (sorted long alphabetics, full name of 1st author only)
  160. #   endif
  161. #   define LAB_ALPH 1
  162. #   define ALPHA_LONG 2
  163. #   define SORTED 1
  164. #   define NAME_FULL 1
  165. #   define ATIT_LOWER 1
  166. #   define MONTH_FULL 1
  167. #   define JOUR_FULL 1
  168. #   define LBKEYS 0
  169. #endif
  170. #ifdef ABBRV
  171. % abbrv style (sorted numbers, with abbreviations)
  172. #   define LAB_ALPH 0
  173. #   define SORTED 1
  174. #   define JOUR_FULL 0
  175. #   define MONTH_FULL 0
  176. #   define ATIT_LOWER 1
  177. #   define NAME_FULL 0
  178. #   define LBKEYS 0
  179. #endif
  180. #ifdef KEY
  181. % keys style (unsorted keys)
  182. #   define LAB_ALPH 1
  183. #   define ALPHA_LONG 2
  184. #   define SORTED 0
  185. #   define NAME_FULL 0
  186. #   define ATIT_LOWER 1
  187. #   define MONTH_FULL 0
  188. #   define JOUR_FULL 1
  189. #   define LBKEYS 1
  190. #endif
  191. #ifdef SKEY
  192. % skeys style (keys, sorted by name of 1st author and year)
  193. #   define LAB_ALPH 1
  194. #   define ALPHA_LONG 2
  195. #   define SORTED 1
  196. #   define NAME_FULL 1
  197. #   define ATIT_LOWER 1
  198. #   define MONTH_FULL 0
  199. #   define JOUR_FULL 1
  200. #   define LBKEYS 1
  201. #endif
  202. #ifdef FRENCH
  203. % French version
  204. #endif FRENCH
  205. %
  206. # if 0
  207. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  208. %    in "A Handbook for Scholars".  Book-like titles are italicized and
  209. %    non-book titles are converted to sentence capitilization
  210. %    (and not enclosed in quotes).
  211. %    This file outputs a \newblock between major blocks of an entry
  212. %    (the name \newblock is analogous to the names \newline and \newpage)
  213. %    so that the user can obtain an "open" format, which has a line break
  214. %    before each block and lines after the first are indented within blocks,
  215. %    by giving an optional \documentstyle argument; currently there is a
  216. %    required `optional' \documentstyle argument, one of
  217. %        opbiba, opbibr, clbiba, or clbibr,
  218. %    giving an open or closed format for an article or report.
  219. %    For the next version of LaTeX there will be just one, truly optional
  220. %    style, for the open format
  221. %    (among other things, it will have improved page breaking).
  222. %    The default will be the "closed" format---blocks runs together.
  223. %
  224. %   Citation alphabetic label format:
  225. %        [Knu73] for single author (or editor or key)
  226. %        [AHU83] (first letters of last names) for multiple authors
  227. %
  228. %   Citation label numberic format:
  229. %        [number]
  230. %
  231. %   Reference list ordering for sorted, alphabetic lables:
  232. %        alphabetical by citation label, then by author(s) or whatever
  233. %        passes for author in the absence of one, and then by title.
  234. %
  235. %   Reference list ordering for sorted, numeric lables:
  236. %        alphabetical by author(s) or whatever passes
  237. %        passes for author in the absence of one, and then by title.
  238. %
  239. %   Reference list ordering for unsorted:
  240. %        by the order cited in the text
  241. %
  242. %   History
  243. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  244. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  245. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik
  246. %    2/17/85    (HWT)    template file and other standard styles made
  247. %    3/28/85        First release, version 0.98b for BibTeX 0.98f
  248. %    5/ 9/85        version 0.98c for BibTeX 0.98i
  249. %             : fixed Theoretical Computer Science macro name
  250. %             : fixed the format.vol.num.pages function
  251. %
  252. % The ENTRY declaration
  253. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  254. %   but no fullauthor or editors fields because BibTeX does name handling.
  255. %   The annote field is commented out here because this family doesn't
  256. %   include an annotated bibliography style
  257. # endif 0
  258.  
  259. ENTRY
  260. % Fields:
  261.   { address
  262. %        Publisher's address
  263. %    annote
  264. %        Long annotation used for annotated bibliographies (begins sentence)
  265.     author
  266. %        Name(s) of author(s), in BibTeX name format
  267.     booktitle
  268. %        Book title when the thing being referenced isn't the whole book.
  269. %        For book entries, the title field should be used instead.
  270.     chapter
  271. %        Chapter number
  272.     edition
  273. %        Edition of a book (e.g., "second")
  274.     editor
  275. %        Name(s) of editor(s), in BibTeX name format.
  276. %        If there is also an author field, then the editor field should be
  277. %        for the book or collection that the work appears in
  278.     howpublished
  279. %         How something strange has been published (begins sentence)
  280.     institution
  281. %        Sponsoring institution
  282.     journal
  283. %        Journal name (macros are provided for many)
  284.     key
  285. %        Alphabetizing and labeling key (needed when no author or editor)
  286.     month
  287. %        Month (macros are provided)
  288.     note
  289. %        To help the reader find a reference (begins sentence)
  290.     number
  291. %        Number of a journal or technical report
  292.     organization
  293. %        Organization (sponsoring a conference)
  294.     pages
  295. %        Page number or numbers (use `--' to separate a range)
  296.     publisher
  297. %        Publisher name
  298.     school
  299. %        School name (for theses)
  300.     series
  301. %        The name of a series or set of books.
  302. %        An individual book will will also have it's own title
  303.     title
  304. %        The title of the thing being referenced
  305.     type
  306. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  307. %        the default "Technical Report"
  308.     volume
  309. %        Volume of a journal or multivolume work
  310.     year
  311. %        Year---should contain only numerals
  312.   }
  313. # if 0
  314. % There are no integer entry variables
  315. # endif 0
  316.   {}
  317. # if 0
  318. % These string entry variables are used to form the citation label.
  319. % In a storage pinch, sort.label can be easily computed on the fly.
  320. # endif 0
  321.  
  322. #if LAB_ALPH
  323. #if SORTED
  324.   { label extra.label sort.label }
  325. #else !SORTED
  326. # if 0
  327. % It still doesn't seem like a good idea to use an order-of-citation
  328. % reference list when using alphabetic labels, but when this happens we
  329. % do things a little differently
  330. # endif 0
  331.   {label}
  332. #endif SORTED
  333. #else !LAB_ALPH
  334.   {label}
  335. #endif LAB_ALPH
  336.  
  337. # if 0
  338. % Each entry function starts by calling output.bibitem, to write the
  339. % \bibitem and its arguments to the .BBL file.  Then the various fields
  340. % are formatted and printed by output or output.check.  Those functions
  341. % handle the writing of separators (commas, periods, \newblock's),
  342. % taking care not to do so when they are passed a null string.
  343. % Finally, fin.entry is called to add the final period and finish the
  344. % entry.
  345. %
  346. % A bibliographic reference is formatted into a number of `blocks':
  347. % in the open format, a block begins on a new line and subsequent
  348. % lines of the block are indented.  A block may contain more than
  349. % one sentence (well, not a grammatical sentence, but something to
  350. % be ended with a sentence ending period).  The entry functions should
  351. % call new.block whenever a block other than the first is about to be
  352. % started.  They should call new.sentence whenever a new sentence is
  353. % to be started.  The output functions will ensure that if two
  354. % new.sentence's occur without any non-null string being output between
  355. % them then there won't be two periods output.  Similarly for two
  356. % successive new.block's.
  357. %
  358. % The output routines don't write their argument immediately.
  359. % Instead, by convention, that argument is saved on the stack to be
  360. % output next time (when we'll know what separator needs to come
  361. % after it).  Meanwhile, the output routine has to pop the pending
  362. % output off the stack, append any needed separator, and write it.
  363. %
  364. % To tell which separator is needed, we maintain an output.state.
  365. % It will be one of these values:
  366. %    before.all        just after the \bibitem
  367. %    mid.sentence        in the middle of a sentence: comma needed
  368. %                    if more sentence is output
  369. %    after.sentence        just after a sentence: period needed
  370. %    after.block        just after a block (and sentence):
  371. %                    period and \newblock needed.
  372. % Note: These styles don't use after.sentence
  373. %
  374. % VAR: output.state : INTEGER        -- state variable for output
  375. %
  376. % The output.nonnull function saves its argument (assumed to be nonnull)
  377. % on the stack, and writes the old saved value followed by any needed
  378. % separator.  The ordering of the tests is decreasing frequency of
  379. % occurrence.
  380. %
  381. % output.nonnull(s) ==
  382. %  BEGIN
  383. %    s := argument on stack
  384. %    if output.state = mid.sentence then
  385. %        write$(pop() * ", ")
  386. %          -- "pop" isn't a function: just use stack top
  387. %    else
  388. %        if output.state = after.block then
  389. %        write$(add.period$(pop()))
  390. %        newline$
  391. %        write$("\newblock ")
  392. %        else
  393. %        if output.state = before.all then
  394. %            write$(pop())
  395. %        else        -- output.state should be after.sentence
  396. %            write$(add.period$(pop()) * " ")
  397. %        fi
  398. %        fi
  399. %    fi
  400. %    push s on stack
  401. %    output.state := mid.sentence
  402. %  END
  403. %
  404. % The output function calls output.nonnull if its argument is non-null
  405. %
  406. % output(s) ==
  407. %  BEGIN
  408. %    if s <> "" then output.nonnull(s)
  409. %    fi
  410. %  END
  411. %
  412. % The output.check function calls output.nonnull if s is non-null
  413. % and warns the user that the t field shouldn't be empty (this is
  414. % because it won't be a good reference without the field;  the entry
  415. % functions try to make the formatting look reasonable even when such
  416. % fields are empty).
  417. %
  418. % output.check(t,s) ==
  419. %  BEGIN
  420. %    if s = "" then
  421. %        top$("Warning: the " * t * " shouldn't be empty in " * cite$)
  422. %    else output.nonnull(s)
  423. %    fi
  424. %  END
  425. %
  426. % The output.bibitem function writes the \bibitem for the current entry
  427. % (the label should already have been set up), and sets up the separator
  428. % state for the output functions.  And, it leaves a string on the stack
  429. % as per the output convention.
  430. %
  431. % output.bibitem ==
  432. %  BEGIN
  433. %    newline$
  434. %    write$("\bibitem[")    % for alphabetic labels,
  435. %    write$(label)        % these three lines
  436. %    write$("]{")        % are used
  437. %    write$("\bibitem{")        % this line for numeric labels
  438. %    write$(cite$)
  439. %    write$("}")
  440. %    push "" on stack
  441. %    output.state := before.all
  442. %  END
  443. %
  444. % The fin.entry function finishes off an entry by adding a period to the
  445. % string remaining on the stack.  If the state is still before.all
  446. % then nothing was produced for this entry, so the result will look bad,
  447. % but the user deserves it. (We don't omit the whole entry because the
  448. % entry was cited, and a bibitem is needed to define the citation label.)
  449. %
  450. % fin.entry ==
  451. %  BEGIN
  452. %    write$(add.period$(pop()))
  453. %    newline$
  454. %  END
  455. %
  456. % The new.block function prepares for a new block to be output, and
  457. % new.sentence prepares for a new sentence.
  458. %
  459. % new.block ==
  460. %  BEGIN
  461. %    if output.state <> before.all then
  462. %        output.state := after.block
  463. %    fi
  464. %  END
  465. %
  466. % new.sentence ==
  467. %  BEGIN
  468. %    if output.state <> after.block then
  469. %        if output.state <> before.all then
  470. %        output.state :=  after.sentence
  471. %        fi
  472. %    fi
  473. %  END
  474. %
  475. # endif 0
  476.  
  477. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  478.  
  479. FUNCTION {init.state.consts}
  480. { 'before.all #0 :=
  481.   'mid.sentence #1 :=
  482.   'after.sentence #2 :=
  483.   'after.block #3 :=
  484. }
  485.  
  486. # if 0
  487. % the variables s and t are temporary string holders
  488. # endif 0
  489.  
  490. STRINGS { s t }
  491.  
  492. FUNCTION {output.nonnull}
  493. { 's swap$ :=
  494.   output.state mid.sentence =
  495.     { ", " * write$ }
  496.     { output.state after.block =
  497.     { add.period$ write$
  498.       newline$
  499.       "\newblock " write$
  500.     }
  501.     { output.state before.all =
  502.         'write$
  503.         { add.period$ " " * write$ }
  504.       if$
  505.     }
  506.       if$
  507.     }
  508.   if$
  509.   'output.state mid.sentence :=
  510.   s
  511. }
  512.  
  513. FUNCTION {output}
  514. { 's swap$ :=
  515.   s "" =
  516.     'skip$
  517.     { s output.nonnull }
  518.   if$
  519. }
  520.  
  521. FUNCTION {output.check}
  522. { 's swap$ :=
  523.   't swap$ :=
  524.   s "" =
  525.     { "Warning: the " t * " shouldn't be empty in " * cite$ * top$ }
  526.     { s output.nonnull }
  527.   if$
  528. }
  529.  
  530. FUNCTION {output.bibitem}
  531. { newline$
  532. #if LAB_ALPH
  533.   "\bibitem[" write$
  534.   label write$
  535.   "]{" write$
  536. #else
  537.   "\bibitem{" write$
  538. #endif
  539.   cite$ write$
  540.   "}" write$
  541.   newline$
  542.   ""
  543.   'output.state before.all :=
  544. }
  545.  
  546. # if 0
  547. % This function finishes all entries.  Note: For an otherwise empty entry
  548. % (which is probably due to a user error) this function prints a
  549. period
  550. # endif 0
  551.  
  552. FUNCTION {fin.entry}
  553. { add.period$
  554.   write$
  555.   newline$
  556. }
  557.  
  558. FUNCTION {new.block}
  559. { output.state before.all =
  560.     'skip$
  561.     { 'output.state after.block := }
  562.   if$
  563. }
  564.  
  565. # if 0
  566. % This function isn't used in these styles
  567. # endif 0
  568.  
  569. FUNCTION {new.sentence}
  570. { output.state after.block =
  571.     'skip$
  572.     { output.state before.all =
  573.     'skip$
  574.     { 'output.state after.sentence := }
  575.       if$
  576.     }
  577.   if$
  578. }
  579.  
  580. # if 0
  581. % These three functions pop one or two (integer) arguments from the stack
  582. % and push a single one, either 0 or 1.
  583. % The 'skip$ in the `and' and `or' functions are used because
  584. % the corresponding if$ would be idempotent
  585. # endif 0
  586.  
  587. FUNCTION {not}
  588. {   { #0 }
  589.     { #1 }
  590.   if$
  591. }
  592.  
  593. FUNCTION {and}
  594. {   'skip$
  595.     { pop$ #0 }
  596.   if$
  597. }
  598.  
  599. FUNCTION {or}
  600. {   { pop$ #1 }
  601.     'skip$
  602.   if$
  603. }
  604.  
  605. # if 0
  606. % Here are some functions for formatting chunks of an entry.
  607. % By convention they either produce a string that can be followed by
  608. % a comma or period (using add.period$, so it is OK to end in a period),
  609. % or they produce the null string.
  610. %
  611. % A useful utility is the field.or.null function, which checks if the
  612. % argument is the result of pushing a `missing' field (one for which no
  613. % assignment was made when the current entry was read in from the database),
  614. % and returns the null string if so, otherwise it returns the field string.
  615. %
  616. % field.or.null(s) ==
  617. %  BEGIN
  618. %    if missing$(s) then return ""
  619. %    else return s
  620. %  END
  621. %
  622. % Another helper function is italicize, which returns the string that
  623. % italicizes the argument string, if that is non-null, otherwise it
  624. % returns the null string.  Italic corrections aren't used, so this
  625. % function should be used when punctation will follow the result.
  626. % Also, it needn't be \em (instead of \it) because the user shouldn't be
  627. % emphasizing the whole bibliography.
  628. %
  629. % italicize(s) ==
  630. %  BEGIN
  631. %    if s = "" then return ""
  632. %    else return "{\it " * s * "}"
  633. %
  634. % The format.names function formats the argument (which should be in
  635. % BibTeX name format) into "First Von~Last, Junior", separated by commas
  636. % and with an "and" before the last (but ending with "et al." if the last
  637. % of multiple authors is "others")
  638. %
  639. % VAR: nameptr, namesleft, numnames: INTEGER
  640. %      nameresult: STRING
  641. %
  642. % format.names(s) ==
  643. %  BEGIN
  644. %    nameptr := 1
  645. %    nameresult := ""
  646. %    numnames := num.names$(s)
  647. %    namesleft := numnames
  648. %    while namesleft > 0
  649. %      do
  650. %                % for full names:
  651. %        t := format.name$(s, nameptr, "{ff }{vv~}{ll}{, jj}")
  652. %                % for abbreviated first names:
  653. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  654. %        if nameptr > 1 then
  655. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  656. %        else if numnames > 2
  657. %               then nameresult := nameresult * ","
  658. %             fi
  659. %             if t = "others"
  660. %               then nameresult := nameresult * " et al."
  661. %               else nameresult := nameresult * " and " * t
  662. %             fi
  663. %        fi
  664. %        else nameresult := nameresult * t
  665. %        fi
  666. %        nameptr := nameptr + 1
  667. %        namesleft := namesleft - 1
  668. %      od
  669. %    return nameresult
  670. %  END
  671. %
  672. % The format.authors function returns the result of format.names(author)
  673. % if the author is present, or else it returns the null string
  674. %
  675. % format.authors ==
  676. %  BEGIN
  677. %    if missing$(author) then return ""
  678. %    else return format.names(author)
  679. %    fi
  680. %  END
  681. %
  682. % Format.editors is like format.authors, but it uses the editor field,
  683. % and appends ", editor" or ", editors"
  684. %
  685. % format.editors ==
  686. %  BEGIN
  687. %    if missing$(editor) then return ""
  688. %    else
  689. %        if num.names$(editor) > 1 then
  690. %        return format.names(editor) * ", editors"
  691. %        else
  692. %        return format.names(editor) * ", editor"
  693. %        fi
  694. %    fi
  695. %  END
  696. %
  697. % Other formatting functions are similar, so no "comment version" will be
  698. % given for them.
  699. %
  700. % The `pop$' in this function gets rid of the duplicate `missing' value and
  701. % the `skip$' returns the duplicate field value
  702. # endif 0
  703.  
  704. FUNCTION {field.or.null}
  705. { duplicate$
  706.   missing$
  707.     { pop$ "" }
  708.     'skip$
  709.   if$
  710. }
  711.  
  712. FUNCTION {italicize}
  713. { 's swap$ :=
  714.   s "" =
  715.     { "" }
  716.     { "{\it " s * "}" * }
  717.   if$
  718. }
  719.  
  720. INTEGERS { nameptr namesleft numnames }
  721.  
  722. STRINGS {nameresult}
  723.  
  724. FUNCTION {format.names}
  725. { 's swap$ :=
  726.   'nameptr #1 :=
  727.   'nameresult "" :=
  728.   'numnames s num.names$ :=
  729.   'namesleft numnames :=
  730.     { namesleft #0 > }
  731.     {
  732. #if NAME_FULL
  733.       't s nameptr "{ff }{vv~}{ll}{, jj}" format.name$ :=
  734. #else
  735.       't s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ :=
  736. #endif
  737.       nameptr #1 >
  738.     { namesleft #1 >
  739.         { 'nameresult nameresult ", " * t * := }
  740.         { numnames #2 >
  741.         { 'nameresult nameresult "," * := }
  742.         'skip$
  743.           if$
  744.           t "others" =
  745.         { 'nameresult nameresult " et al." * := }
  746. #ifndef FRENCH
  747.         { 'nameresult nameresult " and " * t * := }
  748. #else FRENCH
  749.         { 'nameresult nameresult " et " * t * := }
  750. #endif FRENCH
  751.           if$
  752.         }
  753.       if$
  754.     }
  755.     { 'nameresult nameresult t * := }
  756.       if$
  757.       'nameptr nameptr #1 + :=
  758.       'namesleft namesleft #1 - :=
  759.     }
  760.   while$
  761.   nameresult
  762. }
  763.  
  764. FUNCTION {format.authors}
  765. { author missing$
  766.     { "" }
  767.     { author format.names }
  768.   if$
  769. }
  770.  
  771. FUNCTION {format.editors}
  772. { editor missing$
  773.     { "" }
  774.     { editor num.names$ #1 >
  775. #ifndef FRENCH
  776.     { editor format.names ", editors" * }
  777.     { editor format.names ", editor" * }
  778. #else FRENCH
  779.     { editor format.names ", \'{e}diteurs" * }
  780.     { editor format.names ", \'{e}diteur" * }
  781. #endif FRENCH
  782.       if$
  783.     }
  784.   if$
  785. }
  786.  
  787. # if 0
  788. % The format.title function is used for non-book-like titles.
  789. % For most styles we convert to lowercase (except for the very first letter),
  790. % and hope the user has brace-surrounded words that need to stay capitilized;
  791. % for some, however, we leave it as it is in the database.
  792. # endif 0
  793.  
  794. FUNCTION {format.title}
  795. #if ATIT_LOWER
  796. { title missing$
  797.     { "" }
  798.     { title "ul" change.case$ }
  799.   if$
  800. #else
  801. { title field.or.null
  802. #endif ATIT_LOWER
  803. }
  804.  
  805. # if 0
  806. % The entry.string.max function is set to BibTeX's ent_str_size constant,
  807. % the maximum length of an entry string variable.
  808. %
  809. % The global.string.max function is set to BibTeX's glob_str_size constant,
  810. % the maximum length of a global string variable.
  811. # endif 0
  812.  
  813. FUNCTION {entry.string.max} { #100 }
  814.  
  815. FUNCTION {global.string.max} { #300 }
  816.  
  817. # if 0
  818. % The n.dashify function makes each single `-' in a string a double `--'
  819. % if it's not already
  820. %
  821. % VAR: pageresult: STRING
  822. %
  823. % n.dashify(s) ==
  824. %  BEGIN
  825. %    t := s
  826. %    pageresult := ""
  827. %    while (not (t = ""))
  828. %      do
  829. %        if (first character of t = "-")
  830. %          then
  831. %        if (next character isn't)
  832. %          then
  833. %            pageresult := pageresult * "--"
  834. %            t := t with the "-" removed
  835. %          else
  836. %            while (first character of t = "-")
  837. %              do
  838. %            pageresult := pageresult * "-"
  839. %            t := t with the "-" removed
  840. %              od
  841. %        fi
  842. %          else
  843. %        pageresult := pageresult * the first character
  844. %        t := t with the first character removed
  845. %        fi
  846. %      od
  847. %    return pageresult
  848. %  END
  849. # endif 0
  850.  
  851. STRINGS {pageresult}
  852.  
  853. FUNCTION {n.dashify}
  854. { 't swap$ :=
  855.   'pageresult "" :=
  856.     { t "" = not }
  857.     { t #1 #1 substring$ "-" =
  858.     { t #1 #2 substring$ "--" = not
  859.         { 'pageresult pageresult "--" * :=
  860.           't t #2 global.string.max substring$ :=
  861.         }
  862.         {   { t #1 #1 substring$ "-" = }
  863.         { 'pageresult pageresult "-" * :=
  864.           't t #2 global.string.max substring$ :=
  865.         }
  866.           while$
  867.         }
  868.       if$
  869.     }
  870.     { 'pageresult pageresult t #1 #1 substring$ * :=
  871.       't t #2 global.string.max substring$ :=
  872.     }
  873.       if$
  874.     }
  875.   while$
  876.   pageresult
  877. }
  878.  
  879. # if 0
  880. % The format.date function is for the month and year, but we give a warning if
  881. % there's a missing year but the month is there, and we return the empty string
  882. % if they're both missing
  883. # endif 0
  884.  
  885. FUNCTION {format.date}
  886. { year missing$
  887.     { month missing$
  888.     { "" }
  889.     { "Warning: there's a month but no year in " cite$ * top$
  890.       month
  891.     }
  892.       if$
  893.     }
  894.     { month missing$
  895.     { year }
  896.     { month " " * year * }
  897.       if$
  898.     }
  899.   if$
  900. }
  901.  
  902. # if 0
  903. % The format.btitle is for formatting the title field when it is a book-like
  904. % entry---the style used here keeps it in uppers-and-lowers and italicizes it.
  905. # endif 0
  906.  
  907. FUNCTION {format.btitle}
  908. { title field.or.null
  909.   italicize
  910. }
  911.  
  912. # if 0
  913. % The format.bvolume function is for formatting the volume number and/or
  914. % series name of a multivolume book.  If the volume field is missing, we
  915. % output either the series field italicized if it exists or the null string
  916. % otherwise.  If both the volume and series fields are there, we assume the
  917. % series field is the title of the whole multivolume work (the title field
  918. % should be the title of the one referred to), and add an "of <series>".
  919. % A tie (~) is put between the "Volume" and the volume number.
  920. % We capitilize Volume because this function is used at the beginning of a
  921. % block.
  922. # endif 0
  923.  
  924. FUNCTION {format.bvolume}
  925. { volume missing$
  926.     { series missing$
  927.     { "" }
  928.     { series italicize }
  929.       if$
  930.     }
  931.     { "Volume~" volume *
  932.       series missing$
  933.     'skip$
  934. #ifndef FRENCH
  935.     { " of " * series italicize * }
  936. #else FRENCH
  937.     { ", s\'{e}rie " * series italicize * }
  938. #endif FRENCH
  939.       if$
  940.     }
  941.   if$
  942. }
  943.  
  944. # if 0
  945. % The format.edition function appends " edition" to the edition, if present.
  946. % We lowercase the edition (it should be something like "Third"), because
  947. % this doesn't start a sentence.
  948. # endif 0
  949.  
  950. FUNCTION {format.edition}
  951. { edition missing$
  952.     { "" }
  953. #ifndef FRENCH
  954.     { edition "ll" change.case$ " edition" * }
  955. #else FRENCH
  956.     { edition "ll" change.case$ " \'{e}dition" * }
  957. #endif FRENCH
  958.   if$
  959. }
  960.  
  961. # if 0
  962. % The format.pages function is used for formatting a page range in a book
  963. % (and in rare circumstances, an article).
  964. % The multi.page.check function examines the page field for a "-" or a ","
  965. % so that format.pages can use "page" instead of "pages" if neither exists.
  966. % Note: global.string.max, set above, here means "take the rest of the string"
  967. %
  968. % VAR: multiresult: INTEGER    (actually, a boolean)
  969. %
  970. % multi.page.check(s) ==
  971. %  BEGIN
  972. %    t := s
  973. %    multiresult := false
  974. %    while ((not multiresult) and (not (t = "")))
  975. %      do
  976. %        if (first character of t = "-" or ",")
  977. %          then multiresult := true
  978. %          else t := t with the first character removed
  979. %        fi
  980. %      od
  981. %    return multiresult
  982. %  END
  983. # endif 0
  984.  
  985. INTEGERS {multiresult}
  986.  
  987. FUNCTION {multi.page.check}
  988. { 't swap$ :=
  989.   'multiresult #0 :=
  990.     { multiresult not
  991.       t "" = not
  992.       and
  993.     }
  994.     { t #1 #1 substring$ "-" =
  995.       t #1 #1 substring$ "," =
  996.       or
  997.     { 'multiresult #1 := }
  998.     { 't t #2 global.string.max substring$ := }
  999.       if$
  1000.     }
  1001.   while$
  1002.   multiresult
  1003. }
  1004.  
  1005. # if 0
  1006. % This function doesn't begin a sentence so "pages" isn't capitalized
  1007. % other functions that use this should keep that in mind
  1008. # endif 0
  1009.  
  1010. FUNCTION {format.pages}
  1011. { pages missing$
  1012.     { "" }
  1013.     { pages multi.page.check
  1014.     { "pages~" pages n.dashify * }
  1015.     { "page~" pages n.dashify * }
  1016.       if$
  1017.     }
  1018.   if$
  1019. }
  1020.  
  1021. # if 0
  1022. % The format.vol.num.pages function is for the volume, number, and page range
  1023. % of a journal article.  We use the format:  vol(number):pages, with minor
  1024. % variations for missing fields.  This doesn't begin a sentence.
  1025. # endif 0
  1026.  
  1027. FUNCTION {format.vol.num.pages}
  1028. { volume field.or.null
  1029.   number missing$
  1030.     'skip$
  1031.     { "(" number * ")" * *
  1032.       volume missing$
  1033.     { "Warning: there's a number but no volume in " cite$ * top$ }
  1034.     'skip$
  1035.       if$
  1036.     }
  1037.   if$
  1038.   pages missing$
  1039.     'skip$
  1040.     { duplicate$ "" =
  1041.     'skip$
  1042.     { ":" * }
  1043.       if$
  1044.       pages n.dashify *
  1045.     }
  1046.   if$
  1047. }
  1048.  
  1049. # if 0
  1050. % The format.chapter.pages puts "chapter~" in front of a chapter number,
  1051. % if present, and then appends the pages, if present.
  1052. % This doesn't begin a sentence.
  1053. # endif 0
  1054.  
  1055. FUNCTION {format.chapter.pages}
  1056. { chapter missing$
  1057.     'format.pages
  1058. #ifndef FRENCH
  1059.     { "chapter~" chapter *
  1060. #else FRENCH
  1061.     { "chapitre~" chapter *
  1062. #endif FRENCH
  1063.       pages missing$
  1064.     'skip$
  1065.     { ", " * format.pages * }
  1066.       if$
  1067.     }
  1068.   if$
  1069. }
  1070.  
  1071. # if 0
  1072. % The format.in.ed.booktitle function is used for starting out a sentence
  1073. % that begins "In <booktitle>", putting an editor before the title if one
  1074. % exists.
  1075. # endif 0
  1076.  
  1077. FUNCTION {format.in.ed.booktitle}
  1078. { booktitle missing$
  1079.     { "" }
  1080.     { 's format.editors :=
  1081.       s "" =
  1082. #ifndef FRENCH
  1083.     { "In " booktitle italicize * }
  1084.     { "In " s * ", " * booktitle italicize * }
  1085. #else FRENCH
  1086.     { "Dans " booktitle italicize * }
  1087.     { "Dans " s * ", " * booktitle italicize * }
  1088. #endif FRENCH
  1089.       if$
  1090.     }
  1091.   if$
  1092. }
  1093.  
  1094. # if 0
  1095. % The format.tr.number makes a string starting with "Technical Report"
  1096. % (or type, if that field is defined), followed by the number if there
  1097. % is one (but return the first part even if there is no number)
  1098. # endif 0
  1099.  
  1100. FUNCTION {format.tr.number}
  1101. { type missing$
  1102. #ifndef FRENCH
  1103.     { "Technical Report" }
  1104. #else FRENCH
  1105.     { "Rapport" }
  1106. #endif FRENCH
  1107.     { type }
  1108.   if$
  1109.   number missing$
  1110.     'skip$
  1111. #ifndef FRENCH
  1112.     { "~" * number * }
  1113. #else FRENCH
  1114.     { " no.~" * number * }
  1115. #endif FRENCH
  1116.   if$
  1117. }
  1118.  
  1119. # if 0
  1120. % Now we define the type functions for all entry types that may appear
  1121. % in the .BIB file---e.g., functions like `book' and `article'.  These
  1122. % are the routines that actually generate the .BBL-file output for
  1123. % the entry.  These must all precede the READ command.  In addition, the
  1124. % style designer should have a function `default.type' for unknown types.
  1125. % Note: The fields (within each list) are listed in order of appearance,
  1126. % except as described for a `proceedings'.
  1127. %
  1128. % The article function is for an article in a journal.
  1129. %    Required fields: author, title, journal, year
  1130. %    Optional fields: volume, number, pages, month, note
  1131. %
  1132. % article ==
  1133. %  BEGIN
  1134. %    output.bibitem
  1135. %    output.check("author",format.authors)
  1136. %    new.block
  1137. %    output.check("title",format.title)
  1138. %    new.block
  1139. %    output.check("journal",italicize(field.or.null(journal)))
  1140. %    output(format.vol.num.pages)
  1141. %    output.check("year",format.date)
  1142. %    new.block
  1143. %    output(field.or.null(note))
  1144. %    fin.entry
  1145. %  END
  1146. %
  1147. % The book function is for a whole book.
  1148. %    Required fields: author or editor, title, publisher, year
  1149. %    Optional fields: volume, series, address, edition, month, note
  1150. %
  1151. % book ==
  1152. %  BEGIN
  1153. %    if missing$(author) then output.check("author and editor",
  1154. %                                format.editors)
  1155. %    else output.check("author",format.authors)
  1156. %    fi
  1157. %    new.block
  1158. %    output.check("title",format.btitle)
  1159. %    new.block
  1160. %    output(format.bvolume)
  1161. %    output.check("publisher",field.or.null(publisher))
  1162. %    output(field.or.null(address))
  1163. %    output(format.edition)
  1164. %    output.check("year",format.date))
  1165. %    new.block
  1166. %    output(field.or.null(note))
  1167. %    fin.entry
  1168. %  END
  1169. %
  1170. % The other entry functions are all quite similar, so no "comment version"
  1171. % will be given for them.
  1172. # endif 0
  1173.  
  1174. FUNCTION {article}
  1175. { output.bibitem
  1176.   "author" format.authors output.check
  1177.   new.block
  1178.   "title" format.title output.check
  1179.   new.block
  1180.   "journal" journal field.or.null italicize output.check
  1181.   format.vol.num.pages output
  1182.   "year" format.date output.check
  1183.   new.block
  1184.   note field.or.null output
  1185.   fin.entry
  1186. }
  1187.  
  1188. FUNCTION {book}
  1189. { output.bibitem
  1190.   author missing$
  1191.     { "author and editor" format.editors output.check }
  1192.     { "author" format.authors output.check }
  1193.   if$
  1194.   new.block
  1195.   "title" format.btitle output.check
  1196.   new.block
  1197.   format.bvolume output
  1198.   "publisher" publisher field.or.null output.check
  1199.   address field.or.null output
  1200.   format.edition output
  1201.   "year" format.date output.check
  1202.   new.block
  1203.   note field.or.null output
  1204.   fin.entry
  1205. }
  1206.  
  1207. # if 0
  1208. % A booklet is a bound thing without a publisher or sponsoring institution
  1209. %    Required: title
  1210. %    Optional: author, howpublished, address, month, year, note
  1211. # endif 0
  1212.  
  1213. FUNCTION {booklet}
  1214. { output.bibitem
  1215.   format.authors output
  1216.   new.block
  1217.   "title" format.btitle output.check
  1218.   new.block
  1219.   howpublished field.or.null output
  1220.   address field.or.null output
  1221.   format.date output
  1222.   new.block
  1223.   note field.or.null output
  1224.   fin.entry
  1225. }
  1226.  
  1227. # if 0
  1228. % For the conference entry type, see inproceedings
  1229. # endif 0
  1230.  
  1231. # if 0
  1232. % An inbook is a piece of a book: either a chapter and/or a page range.
  1233. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1234. %    Optional: volume, series, address, edition, month, note
  1235. # endif 0
  1236.  
  1237. FUNCTION {inbook}
  1238. { output.bibitem
  1239.   author missing$
  1240.     { "author and editor" format.editors output.check }
  1241.     { "author" format.authors output.check }
  1242.   if$
  1243.   new.block
  1244.   "title" format.btitle output.check
  1245.   "chapter and pages" format.chapter.pages output.check
  1246.   new.block
  1247.   format.bvolume output
  1248.   "publisher" publisher field.or.null output.check
  1249.   address field.or.null output
  1250.   format.edition output
  1251.   "year" format.date output.check
  1252.   new.block
  1253.   note field.or.null output
  1254.   fin.entry
  1255. }
  1256.  
  1257. # if 0
  1258. % An incollection is like inbook, but where there is a separate title
  1259. % for the referenced thing (and perhaps an editor for the whole)
  1260. %    Required: author, title, booktitle, publisher, year
  1261. %    Optional: editor, chapter, pages, address, month, note
  1262. # endif 0
  1263.  
  1264. FUNCTION {incollection}
  1265. { output.bibitem
  1266.   "authors" format.authors output.check
  1267.   new.block
  1268.   "title" format.title output.check
  1269.   new.block
  1270.   "booktitle" format.in.ed.booktitle output.check
  1271.   format.chapter.pages output
  1272.   "publisher" publisher field.or.null output.check
  1273.   address field.or.null output
  1274.   "year" format.date output.check
  1275.   new.block
  1276.   note field.or.null output
  1277.   fin.entry
  1278. }
  1279.  
  1280. # if 0
  1281. % An inproceedings is an article in a conference proceedings
  1282. %    Required: author, title, booktitle, year
  1283. %    Optional: editor, pages, organization, publisher, address, month, note
  1284. # endif 0
  1285.  
  1286. FUNCTION {inproceedings}
  1287. { output.bibitem
  1288.   "author" format.authors output.check
  1289.   new.block
  1290.   "title" format.title output.check
  1291.   new.block
  1292.   "booktitle" format.in.ed.booktitle output.check
  1293.   format.pages output
  1294.   organization field.or.null output
  1295.   publisher field.or.null output
  1296.   address field.or.null output
  1297.   "year" format.date output.check
  1298.   new.block
  1299.   note field.or.null output
  1300.   fin.entry
  1301. }
  1302.  
  1303. # if 0
  1304. % The conference function is included for Scribe compatibility
  1305. # endif 0
  1306.  
  1307. FUNCTION {conference} { inproceedings }
  1308.  
  1309. # if 0
  1310. % A manual is technical documentation
  1311. %    Required: title
  1312. %    Optional: author, organization, address, edition, month, year, note
  1313. # endif 0
  1314.  
  1315. FUNCTION {manual}
  1316. { output.bibitem
  1317.   format.authors output
  1318.   new.block
  1319.   "title" format.btitle output.check
  1320.   new.block
  1321.   organization field.or.null output
  1322.   address field.or.null output
  1323.   format.edition output
  1324.   format.date output
  1325.   new.block
  1326.   note field.or.null output
  1327.   fin.entry
  1328. }
  1329.  
  1330. # if 0
  1331. % A mastersthesis is a Master's thesis
  1332. %    Required: author, title, school, year
  1333. %    Optional: address, month, note
  1334. # endif 0
  1335.  
  1336. FUNCTION {mastersthesis}
  1337. { output.bibitem
  1338.   "author" format.authors output.check
  1339.   new.block
  1340.   "title" format.btitle output.check
  1341.   new.block
  1342. #ifndef FRENCH
  1343.   "Master's thesis" output
  1344. #else FRENCH
  1345.   "Rapport de ma\^{\i}trise" output
  1346. #endif FRENCH
  1347.   "school" school field.or.null output.check
  1348.   address field.or.null output
  1349.   "year" format.date output.check
  1350.   new.block
  1351.   note field.or.null output
  1352.   fin.entry
  1353. }
  1354.  
  1355. # if 0
  1356. % added for France: rapport de DEA, like master's thesis
  1357. # endif 0
  1358.  
  1359. FUNCTION {deathesis}
  1360. { output.bibitem
  1361.   "author" format.authors output.check
  1362.   new.block
  1363.   "title" format.btitle output.check
  1364.   new.block
  1365. #ifdef FRENCH
  1366.   "Rapport de DEA" output
  1367. #else
  1368.   "Dipl\^{o}me d'Etudes Approfondies Thesis" output
  1369. #endif FRENCH
  1370.   "school" school field.or.null output.check
  1371.   address field.or.null output
  1372.   "year" format.date output.check
  1373.   new.block
  1374.   note field.or.null output
  1375.   fin.entry
  1376. }
  1377.  
  1378. # if 0
  1379. % a misc is something that doesn't fit elsewhere
  1380. %    Required: none
  1381. %    Optional: author, title, howpublished, month, year, note
  1382. # endif 0
  1383.  
  1384. FUNCTION {misc}
  1385. { output.bibitem
  1386.   format.authors output
  1387.   new.block
  1388.   format.title output
  1389.   new.block
  1390.   howpublished field.or.null output
  1391.   format.date output
  1392.   new.block
  1393.   note field.or.null output
  1394.   fin.entry
  1395. }
  1396.  
  1397. # if 0
  1398. % A phdthesis is like a mastersthesis
  1399. %    Required: author, title, school, year
  1400. %    Optional: address, month, note
  1401. # endif 0
  1402.  
  1403. FUNCTION {phdthesis}
  1404. { output.bibitem
  1405.   "author" format.authors output.check
  1406.   new.block
  1407.   "title" format.btitle output.check
  1408.   new.block
  1409. #ifndef FRENCH
  1410.   "PhD thesis" output
  1411. #else FRENCH
  1412.   "Th\`{e}se de Doctorat" output
  1413. #endif FRENCH
  1414.   "school" school field.or.null output.check
  1415.   address field.or.null output
  1416.   "year" format.date output.check
  1417.   new.block
  1418.   note field.or.null output
  1419.   fin.entry
  1420. }
  1421.  
  1422. # if 0
  1423. % a proceedings is a conference proceedings
  1424. % if there is an organization but no editor field, the organization will
  1425. % appear as the first optional field (we try to make the first block nonempty)
  1426. %    Required: title, year
  1427. %    Optional: editor, publisher, organization, address, month, note
  1428. # endif 0
  1429.  
  1430. FUNCTION {proceedings}
  1431. { output.bibitem
  1432.   editor missing$
  1433.     { organization missing$
  1434.     'skip$
  1435.     { organization field.or.null output }
  1436.       if$
  1437.     }
  1438.     { format.editors output }
  1439.   if$
  1440.   new.block
  1441.   "title" format.btitle output.check
  1442.   editor missing$
  1443.     'skip$
  1444.     { organization field.or.null output }
  1445.   if$
  1446.   publisher field.or.null output
  1447.   address field.or.null output
  1448.   "year" format.date output.check
  1449.   new.block
  1450.   note field.or.null output
  1451.   fin.entry
  1452. }
  1453.  
  1454. # if 0
  1455. % a techreport is a technical report.
  1456. %    Required: author, title, institution, year
  1457. %    Optional: type, number, address, month, note
  1458. # endif 0
  1459.  
  1460. FUNCTION {techreport}
  1461. { output.bibitem
  1462.   "author" format.authors output.check
  1463.   new.block
  1464.   "title" format.btitle output.check
  1465.   new.block
  1466.   format.tr.number output
  1467.   "institution" institution field.or.null output.check
  1468.   address field.or.null output
  1469.   "year" format.date output.check
  1470.   new.block
  1471.   note field.or.null output
  1472.   fin.entry
  1473. }
  1474.  
  1475. # if 0
  1476. % an unpublished is something that hasn't been published
  1477. %    Required: author, title, note
  1478. %    Optional: month, year
  1479. # endif 0
  1480.  
  1481. FUNCTION {unpublished}
  1482. { output.bibitem
  1483.   "author" format.authors output.check
  1484.   new.block
  1485.   "title" format.title output.check
  1486.   new.block
  1487.   format.date output
  1488.   new.block
  1489.   "note" note field.or.null output.check
  1490.   fin.entry
  1491. }
  1492.  
  1493. # if 0
  1494. % We use entry type book for an unknown type and give a warning
  1495. # endif 0
  1496.  
  1497. FUNCTION {default.type} { book }
  1498.  
  1499. # if 0
  1500. % Here are macros for common things that may vary from style to style.
  1501. % Users are encouraged to use these macros.
  1502. %
  1503. % Months are either written out in full or abbreviated
  1504. # endif 0
  1505.  
  1506. #if MONTH_FULL
  1507.  
  1508. #ifndef FRENCH
  1509. MACRO {jan} {"January"}
  1510. #else FRENCH
  1511. MACRO {jan} {"janvier"}
  1512. #endif FRENCH
  1513.  
  1514. #ifndef FRENCH
  1515. MACRO {feb} {"February"}
  1516. #else FRENCH
  1517. MACRO {feb} {"f\'{e}vrier"}
  1518. #endif FRENCH
  1519.  
  1520. #ifndef FRENCH
  1521. MACRO {mar} {"March"}
  1522. #else FRENCH
  1523. MACRO {mar} {"mars"}
  1524. #endif FRENCH
  1525.  
  1526. #ifndef FRENCH
  1527. MACRO {apr} {"April"}
  1528. #else FRENCH
  1529. MACRO {apr} {"avril"}
  1530. #endif FRENCH
  1531.  
  1532. #ifndef FRENCH
  1533. MACRO {may} {"May"}
  1534. #else FRENCH
  1535. MACRO {may} {"mai"}
  1536. #endif FRENCH
  1537.  
  1538. #ifndef FRENCH
  1539. MACRO {jun} {"June"}
  1540. #else FRENCH
  1541. MACRO {jun} {"juin"}
  1542. #endif FRENCH
  1543.  
  1544. #ifndef FRENCH
  1545. MACRO {jul} {"July"}
  1546. #else FRENCH
  1547. MACRO {jul} {"juillet"}
  1548. #endif FRENCH
  1549.  
  1550. #ifndef FRENCH
  1551. MACRO {aug} {"August"}
  1552. #else FRENCH
  1553. MACRO {aug} {"ao\^{u}t"}
  1554. #endif FRENCH
  1555.  
  1556. #ifndef FRENCH
  1557. MACRO {sep} {"September"}
  1558. #else FRENCH
  1559. MACRO {sep} {"septembre"}
  1560. #endif FRENCH
  1561.  
  1562. #ifndef FRENCH
  1563. MACRO {oct} {"October"}
  1564. #else FRENCH
  1565. MACRO {oct} {"octobre"}
  1566. #endif FRENCH
  1567.  
  1568. #ifndef FRENCH
  1569. MACRO {nov} {"November"}
  1570. #else FRENCH
  1571. MACRO {nov} {"novembre"}
  1572. #endif FRENCH
  1573.  
  1574. #ifndef FRENCH
  1575. MACRO {dec} {"December"}
  1576. #else FRENCH
  1577. MACRO {dec} {"d\'{e}cembre"}
  1578. #endif FRENCH
  1579.  
  1580. #else !MONTH_FULL
  1581.  
  1582. #ifndef FRENCH
  1583. MACRO {jan} {"Jan."}
  1584. #else FRENCH
  1585. MACRO {jan} {"jan."}
  1586. #endif FRENCH
  1587.  
  1588. #ifndef FRENCH
  1589. MACRO {feb} {"Feb."}
  1590. #else FRENCH
  1591. MACRO {feb} {"f\'{e}v."}
  1592. #endif FRENCH
  1593.  
  1594. #ifndef FRENCH
  1595. MACRO {mar} {"March"}
  1596. #else FRENCH
  1597. MACRO {mar} {"mars"}
  1598. #endif FRENCH
  1599.  
  1600. #ifndef FRENCH
  1601. MACRO {apr} {"Apr."}
  1602. #else FRENCH
  1603. MACRO {apr} {"avr."}
  1604. #endif FRENCH
  1605.  
  1606. #ifndef FRENCH
  1607. MACRO {may} {"May"}
  1608. #else FRENCH
  1609. MACRO {may} {"mai"}
  1610. #endif FRENCH
  1611.  
  1612. #ifndef FRENCH
  1613. MACRO {jun} {"June"}
  1614. #else FRENCH
  1615. MACRO {jun} {"juin"}
  1616. #endif FRENCH
  1617.  
  1618. #ifndef FRENCH
  1619. MACRO {jul} {"July"}
  1620. #else FRENCH
  1621. MACRO {jul} {"juil."}
  1622. #endif FRENCH
  1623.  
  1624. #ifndef FRENCH
  1625. MACRO {aug} {"Aug."}
  1626. #else FRENCH
  1627. MACRO {aug} {"ao\^{u}t"}
  1628. #endif FRENCH
  1629.  
  1630. #ifndef FRENCH
  1631. MACRO {sep} {"Sep."}
  1632. #else FRENCH
  1633. MACRO {sep} {"sep."}
  1634. #endif FRENCH
  1635.  
  1636. #ifndef FRENCH
  1637. MACRO {oct} {"Oct."}
  1638. #else FRENCH
  1639. MACRO {oct} {"oct."}
  1640. #endif FRENCH
  1641.  
  1642. #ifndef FRENCH
  1643. MACRO {nov} {"Nov."}
  1644. #else FRENCH
  1645. MACRO {nov} {"nov."}
  1646. #endif FRENCH
  1647.  
  1648. #ifndef FRENCH
  1649. MACRO {dec} {"Dec."}
  1650. #else FRENCH
  1651. MACRO {dec} {"d\'{e}c."}
  1652. #endif FRENCH
  1653.  
  1654. #endif MONTH_FULL
  1655.  
  1656. # if 0
  1657. % Journals are either written out in full or abbreviated;
  1658. % the abbreviations are like those found in ACM publications.
  1659. %
  1660. % To get a completely different set of abbreviations, it may be best to make
  1661. % a separate .bib file with nothing but those abbreviations; users could then
  1662. % include that file name as the first argument to the \bibliography command
  1663. # endif 0
  1664.  
  1665. #if JOUR_FULL
  1666.  
  1667. MACRO {acmcs} {"ACM Computing Surveys"}
  1668.  
  1669. MACRO {acta} {"Acta Informatica"}
  1670.  
  1671. MACRO {cacm} {"Communications of the ACM"}
  1672.  
  1673. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  1674.  
  1675. MACRO {ibmsj} {"IBM Systems Journal"}
  1676.  
  1677. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  1678.  
  1679. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  1680.  
  1681. MACRO {ieeetcad}
  1682.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  1683.  
  1684. MACRO {ipl} {"Information Processing Letters"}
  1685.  
  1686. MACRO {jacm} {"Journal of the ACM"}
  1687.  
  1688. MACRO {jcss} {"Journal of Computer and System Sciences"}
  1689.  
  1690. MACRO {scp} {"Science of Computer Programming"}
  1691.  
  1692. MACRO {sicomp} {"SIAM Journal on Computing"}
  1693.  
  1694. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  1695.  
  1696. MACRO {tods} {"ACM Transactions on Database Systems"}
  1697.  
  1698. MACRO {tog} {"ACM Transactions on Graphics"}
  1699.  
  1700. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  1701.  
  1702. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  1703.  
  1704. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  1705.  
  1706. MACRO {tcs} {"Theoretical Computer Science"}
  1707.  
  1708. #ifdef FRENCH
  1709. MACRO {tsi} {"Technique et Science Informatiques"}
  1710.  
  1711. #endif FRENCH
  1712. #else !JOUR_FULL
  1713.  
  1714. MACRO {acmcs} {"ACM Comput. Surv."}
  1715.  
  1716. MACRO {acta} {"Acta Inf."}
  1717.  
  1718. MACRO {cacm} {"Commun. ACM"}
  1719.  
  1720. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  1721.  
  1722. MACRO {ibmsj} {"IBM Syst. J."}
  1723.  
  1724. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  1725.  
  1726. MACRO {ieeetc} {"IEEE Trans. Comput."}
  1727.  
  1728. MACRO {ieeetcad}
  1729.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  1730.  
  1731. MACRO {ipl} {"Inf. Process. Lett."}
  1732.  
  1733. MACRO {jacm} {"J. ACM"}
  1734.  
  1735. MACRO {jcss} {"J. Comput. Syst. Sci."}
  1736.  
  1737. MACRO {scp} {"Sci. Comput. Programming"}
  1738.  
  1739. MACRO {sicomp} {"SIAM J. Comput."}
  1740.  
  1741. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  1742.  
  1743. MACRO {tods} {"ACM Trans. Database Syst."}
  1744.  
  1745. MACRO {tog} {"ACM Trans. Gr."}
  1746.  
  1747. MACRO {toms} {"ACM Trans. Math. Softw."}
  1748.  
  1749. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  1750.  
  1751. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  1752.  
  1753. MACRO {tcs} {"Theoretical Comput. Sci."}
  1754.  
  1755. MACRO {tsi} {"Technique et Science Informatiques"}
  1756.  
  1757. #endif JOUR_FULL
  1758.  
  1759. # if 0
  1760. % Now we read in the .BIB entries.
  1761. # endif 0
  1762.  
  1763. READ
  1764.  
  1765. # if 0
  1766. % The sortify function converts to lower case after purify$ing; it's
  1767. % used in sorting and in computing alphabetic labels after sorting
  1768. # endif 0
  1769.  
  1770. #if SORTED
  1771.  
  1772. FUNCTION {sortify}
  1773. { purify$
  1774.   "ll" change.case$
  1775. }
  1776.  
  1777. #endif SORTED
  1778.  
  1779. # if 0
  1780. % This long comment applies only to alphabetic labels
  1781. %
  1782. % The format.lab.names function makes a short label by using the initials of
  1783. % the von and Last parts of the names (but if there are more than four names,
  1784. % (i.e., people) it truncates after three and adds a "*";
  1785. % it also adds a "*" if the last of multiple authors is "others").
  1786. % If there is only one name, and its von and Last parts combined have just
  1787. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  1788. % we take the first three letters of the last name.
  1789. % In the LONG and ALPHA3 styles, only the name of the first author is
  1790. % considered.
  1791. % In the KEY and SKEY styles, the label is equal to the citation key.
  1792. %
  1793. % format.lab.names(s) ==
  1794. %  BEGIN
  1795. %    numnames := num.names$(s)
  1796. %    if numnames > 1 then
  1797. %        if numnames > 4 then
  1798. %        namesleft := 3
  1799. %        else
  1800. %        namesleft := numnames
  1801. %        nameptr := 1
  1802. %        nameresult := ""
  1803. %        while namesleft > 0
  1804. %          do
  1805. %        if (name_ptr = numnames) and
  1806. %            format.name$(s, nameptr, "{ff}{vv}{ll}{jj}") = "others"
  1807. %            then nameresult := nameresult * "*"
  1808. %            else nameresult := nameresult *
  1809. %                format.name$(s, nameptr, "{v{}}{l{}}")
  1810. %        nameptr := nameptr + 1
  1811. %        namesleft := namesleft - 1
  1812. %          od
  1813. %        if numnames > 4 then
  1814. %        nameresult := nameresult * "*"
  1815. %    else
  1816. %        t := format.name$(s, 1, "{v{}}{l{}}")
  1817. %        if substring$(t, 2, 1) = "" then    % there's just one name-token
  1818. %        nameresult := substring$(purify$(format.name$(s, 1, "{ll}")),
  1819. %                                    1, 3)
  1820. %        else
  1821. %        nameresult := t
  1822. %        fi
  1823. %    fi
  1824. %    nameresult
  1825. %  END
  1826. %
  1827. % Here is a function for calculating the preliminary label of an entry.
  1828. % It is formed by calculating format.lab.names on the author field
  1829. % (or on the editor field if there is no author, or using the first three
  1830. % letters of the key field if there is no editor either), and appending the
  1831. % last two characters (digits) of the year.  It is an error if there is no
  1832. % author, editor or key field, and we use the first three letters of the title
  1833. % in desperation when this happens.  The resulting label is purify$ed, except
  1834. % for possibly a "*" if there are too many authors.
  1835. %
  1836. % This function also calculates the version of this label to be used in sorting
  1837. %
  1838. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  1839. % otherwise identical labels, but we can't calculated those "extra.label"s
  1840. % until after sorting.
  1841. %
  1842. % calc.label ==
  1843. %  BEGIN
  1844. %    if missing$(author) then
  1845. %        if missing$(editor) then
  1846. %        if missing$(key) then
  1847. %            top$("Warning: need a key to make a label in " * cite$)
  1848. %            label := substring$(purify$(field.or.null(title)), 1, 3)
  1849. %        else
  1850. %            label := substring$(purify$(key), 1, 3)
  1851. %        fi
  1852. %        else
  1853. %        label := format.lab.names(editor)
  1854. %        fi
  1855. %    else
  1856. %        label := format.lab.names(author)
  1857. %    fi
  1858. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  1859. %        % assuming we will also sort, we calculate a sort.label
  1860. %    sort.label := sortify(label)
  1861. %  END
  1862. %
  1863. % In the case of the SKEY style, compute the sort.label as above, but do
  1864. %       label := cite$
  1865. % In the case of the KEY style, the above computation is done but not used.
  1866. % It really should be taken out, but what the heck.
  1867. # endif 0
  1868.  
  1869. #if LAB_ALPH
  1870.  
  1871. FUNCTION {format.lab.names}
  1872. { 's swap$ :=
  1873. #if !ALPHA_LONG
  1874.   'numnames s num.names$ :=
  1875.   numnames #1 >
  1876.     { numnames #4 >
  1877.     { 'namesleft #3 := }
  1878.     { 'namesleft numnames := }
  1879.       if$
  1880.       'nameptr #1 :=
  1881.       'nameresult "" :=
  1882.     { namesleft #0 > }
  1883.     { nameptr numnames =
  1884.         { s nameptr "{ff}{vv}{ll}{jj}" format.name$ "others" =
  1885.         { 'nameresult nameresult "*" * := }
  1886.         { 'nameresult nameresult s nameptr "{v{}}{l{}}" format.name$
  1887.           * :=
  1888.         }
  1889.           if$
  1890.         }
  1891.         { 'nameresult nameresult s nameptr "{v{}}{l{}}" format.name$
  1892.           * :=
  1893.         }
  1894.       if$
  1895.       'nameptr nameptr #1 + :=
  1896.       'namesleft namesleft #1 - :=
  1897.     }
  1898.       while$
  1899.       numnames #4 >
  1900.     { 'nameresult nameresult "*" * := }
  1901.     'skip$
  1902.       if$
  1903.     }
  1904.     { 
  1905. #endif ALPHA_LONG
  1906.  
  1907.       't s #1 "{v{}}{l{}}" format.name$ :=
  1908.  
  1909.       'nameresult
  1910.       t #2 #1 substring$ "" =
  1911.  
  1912. #if ALPHA_LONG<2
  1913.     { s #1 "{ll}" format.name$ purify$ #1 #3 substring$ }
  1914. #else ALPHA_LONG
  1915.         { s #1 "{ll}" format.name$ purify$ }
  1916. #endif ALPHA_LONG
  1917.  
  1918.     { t }
  1919.       if$
  1920.       :=
  1921.  
  1922. #if !ALPHA_LONG
  1923.     }
  1924.   if$
  1925. #endif ALPHA_LONG
  1926.  
  1927.   nameresult
  1928. }
  1929.  
  1930. FUNCTION {calc.label}
  1931. { 'label
  1932.   author missing$
  1933.     { editor missing$
  1934.     { key missing$
  1935.         { "Warning: need a key to make a label in " cite$ * top$
  1936.           title field.or.null purify$ #1 #3 substring$
  1937.         }
  1938.         { key purify$ #1 #3 substring$ }
  1939.       if$
  1940.     }
  1941.     { editor format.lab.names }
  1942.       if$
  1943.     }
  1944.     { author format.lab.names }
  1945.   if$
  1946. #ifdef PAREN
  1947.   " (" year field.or.null purify$ #-1 #2 substring$ * ")" *
  1948. #else !PAREN
  1949. #  if ALPHA_LONG>1
  1950.   " " year field.or.null purify$ #-1 #2 substring$ *
  1951. #  else ALPHA_LONG<=1
  1952.   year field.or.null purify$ #-1 #2 substring$
  1953. #  endif ALPHA_LONG
  1954. #endif PAREN
  1955.   *
  1956.   :=
  1957. #if SORTED
  1958.   'sort.label label sortify :=
  1959. #endif SORTED
  1960. #if LBKEYS
  1961.   'label cite$ :=
  1962. #endif LBKEYS
  1963. }
  1964.  
  1965. # if 0
  1966. % It doesn't seem like a particularly good idea to use an order-of-citation
  1967. % reference list when using alphabetic labels, but we need to have a
  1968. % special pass to calculate labels when this happens.
  1969. # endif 0
  1970.  
  1971. #if !SORTED
  1972.  
  1973. ITERATE {calc.label}
  1974.  
  1975. #endif !SORTED
  1976.  
  1977. #endif LAB_ALPH
  1978.  
  1979. # if 0
  1980. % When sorting, we compute the sortkey by executing "presort" on each entry.
  1981. % The presort key contains a number of "sortify"ed strings, concatenated
  1982. % with multiple blanks between them.  This makes things like "brinch  per"
  1983. % come before "brinch hansen  per"
  1984. %
  1985. % The fields used here are:
  1986. % the sort.label for alphabetic labels (as set by calc.label),
  1987. % followed by the author names (or editor names, if those are missing,
  1988. % or the key field if both are), followed by the first bit
  1989. % of the title (chopping off a leading "The ", "A ", or "An ").
  1990. % Names are formatted: Von Last First Junior.
  1991. % The names within a part will be separated by a single blank
  1992. % (such as "brinch hansen"), two will separate the name parts themselves
  1993. % (except the von and last), three will separate the names,
  1994. % and four will separate the names from the title (and label, if alphabetic).
  1995. %
  1996. % The sort.format.names function takes an argument that should be in
  1997. % BibTeX name format, and returns a string containing "   "-separated
  1998. % names in the format described above.  The function is almost the same
  1999. % as format.names.
  2000. # endif 0
  2001.  
  2002. #if SORTED
  2003.  
  2004. FUNCTION {sort.format.names}
  2005. { 's swap$ :=
  2006.   'nameptr #1 :=
  2007.   'nameresult "" :=
  2008.   'numnames s num.names$ :=
  2009.   'namesleft numnames :=
  2010.     { namesleft #0 > }
  2011.     { nameptr #1 >
  2012.     { 'nameresult nameresult "   " * := }
  2013.     'skip$
  2014.       if$
  2015. #if NAME_FULL
  2016.       't s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ :=
  2017. #else
  2018.       't s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ :=
  2019. #endif NAME_FULL
  2020.       nameptr numnames = t "others" = and
  2021.     { 'nameresult nameresult "et al" * := }
  2022.     { 'nameresult nameresult t sortify * := }
  2023.       if$
  2024.       'nameptr nameptr #1 + :=
  2025.       'namesleft namesleft #1 - :=
  2026.     }
  2027.   while$
  2028.   nameresult
  2029. }
  2030.  
  2031. # if 0
  2032. % The chop.word(w,len,s) function returns either s or, if the first len
  2033. % letters of s equals w (this comparison is done in the third line of the
  2034. % function's definition), it returns that part of s after w.
  2035. # endif 0
  2036.  
  2037. INTEGERS {len}
  2038.  
  2039. FUNCTION {chop.word}
  2040. { 's swap$ :=
  2041.   'len swap$ :=
  2042.   s #1 len substring$ =
  2043.     { s len #1 + global.string.max substring$ }
  2044.     { s }
  2045.   if$
  2046. }
  2047.  
  2048. # if 0
  2049. % The sort.format.title function returns the argument,
  2050. % but first any leading "A "'s, "An "'s, or "The "'s are removed.
  2051. % The chop.word function uses s, so we need another string variable, t
  2052. # endif 0
  2053.  
  2054. FUNCTION {sort.format.title}
  2055. { 't swap$ :=
  2056.   "A " #2
  2057.     "An " #3
  2058.       "The " #4 t chop.word
  2059.     chop.word
  2060.   chop.word
  2061.   #1 global.string.max substring$
  2062.   sortify
  2063. }
  2064.  
  2065. # if 0
  2066. % There is a limit on the length of an entry string variable, which
  2067. % is what its sort.key$ is.  The limit is currently entry.string.max, so we
  2068. % take at most that many characters of the constructed key, and hope
  2069. % there aren't many references that match to that many characters!
  2070. # endif 0
  2071.  
  2072. FUNCTION {presort}
  2073. {
  2074. #if LAB_ALPH
  2075.   calc.label
  2076.   sort.label
  2077.   "    "
  2078.   *
  2079. #endif LAB_ALPH
  2080.   author missing$
  2081.     { editor missing$
  2082.     { key field.or.null sortify }
  2083.     { editor sort.format.names }
  2084.       if$
  2085.     }
  2086.     { author sort.format.names }
  2087.   if$
  2088. #if LAB_ALPH
  2089.   *
  2090. #endif LAB_ALPH
  2091.   "    "
  2092.   *
  2093.   title field.or.null
  2094.   sort.format.title
  2095.   *
  2096.   #1 entry.string.max substring$
  2097.   'sort.key$ swap$ :=
  2098. }
  2099.  
  2100. ITERATE {presort}
  2101.  
  2102. # if 0
  2103. % And now we can sort
  2104. # endif 0
  2105.  
  2106. SORT
  2107.  
  2108. #endif SORTED
  2109.  
  2110. # if 0
  2111. % This long comment applies only to alphabetic labels, when sorted
  2112. %
  2113. % Now comes the final computation for alphabetic labels, putting in the 'a's
  2114. % and 'b's and so forth if required.  This involves two passes: a forward
  2115. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  2116. % to put in the 'a's (we don't want to put in 'a's unless we know there
  2117. % are 'b's).  However this is not necessary in the 'skeys' style.
  2118. % We have to keep track of the longest (in width$ terms) label, for use
  2119. % by the "thebibliography" environment.
  2120. %
  2121. % VAR: longest.label, last.sort.label, next.extra: string
  2122. %      longest.label.width, last.extra.num: integer
  2123. %
  2124. % initialize.longest.label ==
  2125. %  BEGIN
  2126. %    longest.label := ""
  2127. %    last.sort.label := ""
  2128. %    next.extra := ""
  2129. %    longest.label.width := 0
  2130. %    last.extra.num := 0
  2131. %  END
  2132. %
  2133. % forward.pass ==
  2134. %  BEGIN
  2135. %    if last.sort.label = sort.label then
  2136. %        last.extra.num := last.extra.num + 1
  2137. %        extra.label := int.to.chr$(last.extra.num)
  2138. %    else
  2139. %        last.extra.num := chr.to.int$("a")
  2140. %        extra.label := ""
  2141. %        last.sort.label := sort.label
  2142. %    fi
  2143. %  END
  2144. %
  2145. % reverse.pass ==
  2146. %  BEGIN
  2147. %    if next.extra = "b" then
  2148. %        extra.label := "a"
  2149. %    fi
  2150. %    label := label * extra.label
  2151. %    if width$(label) > longest.label.width then
  2152. %        longest.label := label
  2153. %        longest.label.width := width$(label)
  2154. %    fi
  2155. %    next.extra := extra.label
  2156. %  END
  2157. # endif 0
  2158.  
  2159. #if LAB_ALPH
  2160.  
  2161. #if SORTED
  2162.  
  2163. STRINGS { longest.label last.sort.label next.extra }
  2164.  
  2165. INTEGERS { longest.label.width last.extra.num }
  2166.  
  2167. FUNCTION {initialize.longest.label}
  2168. { 'longest.label "" :=
  2169.   'last.sort.label "" :=
  2170.   'next.extra "" :=
  2171.   'longest.label.width #0 :=
  2172.   'last.extra.num #0 :=
  2173. }
  2174.  
  2175. #   ifndef SKEY
  2176. FUNCTION {forward.pass}
  2177. { last.sort.label sort.label =
  2178.     { 'last.extra.num last.extra.num #1 + :=
  2179.       'extra.label last.extra.num int.to.chr$ :=
  2180.     }
  2181.     { 'last.extra.num "a" chr.to.int$ :=
  2182.       'extra.label "" :=
  2183.       'last.sort.label sort.label :=
  2184.     }
  2185.   if$
  2186. }
  2187. #   endif SKEY
  2188.  
  2189. FUNCTION {reverse.pass}
  2190. #  ifndef SKEY
  2191.   next.extra "b" =
  2192.     { 'extra.label "a" := }
  2193.     'skip$
  2194.   if$
  2195.   'label label extra.label * :=
  2196. #  endif SKEY
  2197.   label width$ longest.label.width >
  2198.     { 'longest.label label :=
  2199.       'longest.label.width label width$ :=
  2200.     }
  2201.     'skip$
  2202.   if$
  2203.   'next.extra extra.label :=
  2204. }
  2205.  
  2206. EXECUTE {initialize.longest.label}
  2207.  
  2208. #   ifndef SKEY
  2209. ITERATE {forward.pass}
  2210. #   endif SKEY
  2211.  
  2212. REVERSE {reverse.pass}
  2213.  
  2214.  
  2215. #else !SORTED
  2216.  
  2217. # if 0
  2218. % It still doesn't seem like a good idea to use an order-of-citation
  2219. % reference list when using alphabetic labels, but when this happens we
  2220. % must compute the longest label
  2221. # endif 0
  2222.  
  2223. STRINGS {longest.label}
  2224.  
  2225. INTEGERS {longest.label.width}
  2226.  
  2227. FUNCTION {initialize.longest.label}
  2228. { 'longest.label "" :=
  2229.   'longest.label.width #0 :=
  2230. }
  2231.  
  2232. FUNCTION {longest.label.pass}
  2233. { label width$ longest.label.width >
  2234.     { 'longest.label label :=
  2235.       'longest.label.width label width$ :=
  2236.     }
  2237.     'skip$
  2238.   if$
  2239. }
  2240.  
  2241. EXECUTE {initialize.longest.label}
  2242.  
  2243. ITERATE {longest.label.pass}
  2244.  
  2245. #endif SORTED
  2246.  
  2247. #else !LAB_ALPH
  2248.  
  2249. # if 0
  2250. % Now comes the computation for numeric labels.
  2251. % We use either the sorted order or original order.
  2252. % We still have to keep track of the longest (in width$ terms) label, for use
  2253. % by the "thebibliography" environment.
  2254. # endif 0
  2255.  
  2256. STRINGS {longest.label}
  2257.  
  2258. INTEGERS { number.label longest.label.width }
  2259.  
  2260. FUNCTION {initialize.longest.label}
  2261. { 'longest.label "" :=
  2262.   'number.label #1  :=
  2263.   'longest.label.width #0 :=
  2264. }
  2265.  
  2266. FUNCTION {longest.label.pass}
  2267. { 'label number.label int.to.str$ :=
  2268.   'number.label number.label #1 + :=
  2269.   label width$ longest.label.width >
  2270.     { 'longest.label label :=
  2271.       'longest.label.width label width$ :=
  2272.     }
  2273.     'skip$
  2274.   if$
  2275. }
  2276.  
  2277. EXECUTE {initialize.longest.label}
  2278.  
  2279. ITERATE {longest.label.pass}
  2280.  
  2281. #endif LAB_ALPH
  2282.  
  2283. # if 0
  2284. % Now we're ready to start writing the .BBL file.
  2285. % First we write the `preamble' containing the command
  2286. %     \begin{thebibliography}{...}
  2287. % where the `...' is the longest label.
  2288. %
  2289. % Then we call init.state.consts, for use by the output routines.
  2290. # endif 0
  2291.  
  2292. FUNCTION {preamble}
  2293. { "\begin{thebibliography}{"  longest.label  * "}" * write$
  2294.   newline$
  2295. }
  2296.  
  2297. EXECUTE {preamble}
  2298.  
  2299. EXECUTE {init.state.consts}
  2300.  
  2301. # if 0
  2302. % Now we produce the output for all the entries
  2303. # endif 0
  2304.  
  2305. ITERATE {call.type$}
  2306.  
  2307. # if 0
  2308. % Finally, we finish up by writing the `\end{thebibliography}' command.
  2309. # endif 0
  2310.  
  2311. FUNCTION {finish.up} { newline$ "\end{thebibliography}" write$ newline$ }
  2312.  
  2313. EXECUTE {finish.up}
  2314.